{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 57,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "12\n"
     ]
    }
   ],
   "source": [
    "# 获取第一行的基本数据信息\n",
    "basic_info = input()\n",
    "# 处理得到的Basic info n,m,k\n",
    "info_list = basic_info.split()\n",
    "# 经验谈，Split之后的结果是一个Char不是Int\n",
    "matrix_size = int(info_list[0])\n",
    "fire_num = int(info_list[1])\n",
    "light_stone_num = int(info_list[2])\n",
    "\n",
    "fire_coordinatation_list = []\n",
    "stone_coordination_list = []\n",
    "# 接收fire_num个坐标信息\n",
    "for index in range(fire_num):\n",
    "    fire_coordinate = input().split()\n",
    "    # print(fire_coordinate)\n",
    "    x,y = fire_coordinate\n",
    "    fire_coordinatation_list.append((int(x)-1,int(y)-1))\n",
    "# 接收light_stone_num个坐标信息\n",
    "for index in range(light_stone_num):\n",
    "    stone_coordinate = input().split()\n",
    "    x,y = stone_coordinate\n",
    "    stone_coordination_list.append((int(x)-1,int(y)-1))\n",
    "    \n",
    "# 构造一个矩阵 其中 0为暗 1为亮\n",
    "matrix = [ [0]*matrix_size for _ in range(matrix_size) ]\n",
    "\n",
    "# print(fire_coordinatation_list)\n",
    "\n",
    "# 点亮火把位置\n",
    "def fire_zone(matrix,coordinate):\n",
    "    # print(coordinate)\n",
    "    x,y = coordinate\n",
    "    # 处理列\n",
    "    for index_x,row in enumerate(matrix):\n",
    "        if index_x == (x-2):\n",
    "            row[y] = 1\n",
    "        if index_x == (x+2):\n",
    "            row[y] = 1\n",
    "        # 处理特殊的四角\n",
    "        if index_x == (x-1):\n",
    "            row[y] = 1\n",
    "            row[y-1] = 1\n",
    "            row[y+1] = 1\n",
    "        if index_x == (x+1):\n",
    "            row[y] = 1\n",
    "            row[y-1] = 1\n",
    "            row[y+1] = 1\n",
    "    # 处理行\n",
    "    left = y - 2\n",
    "    if left < 0:\n",
    "        left = 0\n",
    "    right = y + 2\n",
    "    if right > len(matrix):\n",
    "        right = len(matrix)\n",
    "    for index,item in enumerate(matrix[x]):\n",
    "        if index >= left and index <= right:\n",
    "            matrix[x][index] = 1\n",
    "    # print(\"处理火把之后的Matrix\",matrix)\n",
    "\n",
    "# 点亮石头位置\n",
    "def stone_zone(matrix,coordinate):\n",
    "    # print(coordinate)\n",
    "    x,y = coordinate\n",
    "    left = y - 2\n",
    "    if left < 0:\n",
    "        left = 0\n",
    "    right = y + 2\n",
    "    if right > len(matrix):\n",
    "        right = len(matrix)\n",
    "    # 处理列\n",
    "    for index_x,row in enumerate(matrix):\n",
    "        if index_x == (x-2):\n",
    "            row[left] = 1\n",
    "            row[left+1] = 1\n",
    "            row[y] = 1\n",
    "            row[right-1] = 1\n",
    "            row[right] = 1\n",
    "        if index_x == (x-1):\n",
    "            row[left] = 1\n",
    "            row[left+1] = 1\n",
    "            row[y] = 1\n",
    "            row[right-1] = 1\n",
    "            row[right] = 1\n",
    "        if index_x == (x+2):\n",
    "            row[left] = 1\n",
    "            row[left+1] = 1\n",
    "            row[y] = 1\n",
    "            row[right-1] = 1\n",
    "            row[right] = 1\n",
    "        if index_x == (x+1):\n",
    "            row[left] = 1\n",
    "            row[left+1] = 1\n",
    "            row[y] = 1\n",
    "            row[right-1] = 1\n",
    "            row[right] = 1\n",
    "    # 处理行\n",
    "    for index,item in enumerate(matrix[x]):\n",
    "        if index >= left and index <= right:\n",
    "            matrix[x][index] = 1\n",
    "    \n",
    "# 计算所有的点亮位置\n",
    "# 处理所有的火把位置\n",
    "for index,item in enumerate(fire_coordinatation_list):\n",
    "    # print(item)\n",
    "    fire_zone(matrix,item)\n",
    "# 处理所有的萤石位置\n",
    "for index,item in enumerate(stone_coordination_list):\n",
    "    stone_zone(matrix,item)\n",
    "    # print(matrix)\n",
    "# print(matrix)\n",
    "# 统计所有的暗处\n",
    "def count_dark(matrix):\n",
    "    count = 0\n",
    "    for index_x,row in enumerate(matrix):\n",
    "        for index_j,item in enumerate(row):\n",
    "            if item == 0:\n",
    "                count += 1\n",
    "    return count \n",
    "print(count_dark(matrix))"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "science39",
   "language": "python",
   "name": "science39"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
